<?php

App::uses('AppModel', 'Model');

/**
 * CustomerContact Model
 *
 */
class CustomerContact extends AppModel {

    /**
     * Validation rules
     *
     * @var array
     */
    public $validate = array(
        'name' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Youre name is require.',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'tel' => array(
            'notEmpty' => array(
                'rule' => array('notEmpty'),
                'message' => 'Youre mobile is require.',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'email' => array(
            'email' => array(
                'rule' => array('email'),
                'message' => 'Youre email is require.',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'province' => array(
            'notEmpty' => array(
                'rule' => array(''),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
    );
    
    
    public function listAllContact(){
        $data = $this->Find('all',array(
            'order'=>'CustomerContact.created desc'
        ));
        return $data;
    }
    
    public function getAllDetails($id){
        $data = $this->Find('first',array(
            'conditions'=>array(
                'CustomerContact.id'=>$id
            )
        ));
        return $data;
    }

}
